<?php
/**
 * Created by PhpStorm.
 * Author: 赵凯
 * Date: 2019/12/10
 * Time: 16:02
 */

namespace api\install\controller;


use api\common\model\RlEtCustInstalRelModel;
use api\common\model\RlHiseServiceProjectModel;

class IndexController extends BaseController
{
    //首页
    public function index(){
        $this->success('请求成功','',['user_info'=>$this->user_info]);
    }

    public function choiceDealer(){
        $where['cui.server_code']= $this->user_info['server_code'];
        $prefix = 'cmf_';
        $field  =   [
            'cu .jxs_mc',
            'cui .jxsbm'
        ];
        $join   =   [
            ["{$prefix}rl_et_customer cu", 'cu.jxsbm=cui.jxsbm'],

        ];
        $list = RlEtCustInstalRelModel:: alias('cui')
                    ->where($where)
                    ->field($field)
                    ->join($join)
                    ->select()
                    ->toArray();
        foreach ($list as $k=>$v){
                $count = RlHiseServiceProjectModel::where('jxs',$v['jxsbm'])->where('azd',$this->user_info['engineer_code'])->where('azd')->count();
                $list[$k]['install_count']= $count;
        }
        $data['user_info'] = $this->user_info;
        $data['data'] = $list;
        $this->success('请求成功','',$data);
    }

}